﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true"
    CodeBehind="ReleaseBillReport.aspx.cs" Inherits="Billing2.ReleaseBillReport" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Src="~/Controls/ucHighlight.ascx" TagName="ucHighlight" TagPrefix="uc3" %>
<%@ Register Src="~/Controls/ucPageTitle.ascx" TagName="ucPageTitle" TagPrefix="uc4" %>
<%@ Register Src="~/Controls/ucInProgress.ascx" TagName="ucInProgress" TagPrefix="uc5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel runat="server" ID="updatePanel1">
        <ContentTemplate>
            <uc3:ucHighlight ID="ucHighlight1" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <uc4:ucPageTitle ID="ucPageTitle1" runat="server" />
    <asp:UpdatePanel runat="server" ID="updatePanel2">
        <ContentTemplate>
            <table cellpadding="0" cellspacing="3" width="100%">
                <tr>
                    <td align="left" width="90px">
                        Billing Period:&nbsp;
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlBillPeriod" runat="server" AutoPostBack="True">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="left" width="100px">
                        Include Old Version:&nbsp;
                    </td>
                    <td>
                        <asp:CheckBox ID="cbIncludeOldVersion" runat="server" Checked="false" />
                    </td>
                </tr>
                <tr>
                    <td align="left" width="90px">
                        Organization:&nbsp;
                    </td>
                    <td align="left" nowrap valign="top">
                        <asp:UpdatePanel ID="updatePanel7" runat="server">
                            <ContentTemplate>
                                <asp:DropDownList ID="ddlOrganization" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlOrganization_SelectedIndexChanged">
                                </asp:DropDownList>
                                &nbsp; Site:&nbsp;
                                <asp:DropDownList ID="ddlSite" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlSite_SelectedIndexChanged">
                                </asp:DropDownList>
                                &nbsp; Cost Centre:&nbsp;
                                <asp:DropDownList ID="ddlCostCentre" runat="server" AutoPostBack="True">
                                </asp:DropDownList>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                </tr>
            </table>
            <br />
            <asp:Button ID="BtnRetrieve" runat="server" CssClass="ui-state-default ui-corner-all"
                Text="Retrieve" Visible="True" OnClick="BtnRetrieve_Click" />
            <br />
            <br />
            <asp:Label ID="lblAvailable" runat="server" Text="Available reports:" Visible="false"></asp:Label>
            <div class="gridDownload">
            <asp:GridView ID="gvwReports" runat="server" CellPadding="4" CssClass="GridViewStyle"
                GridLines="Horizontal" AutoGenerateColumns="False" AllowSorting="True" onsorting="gvwReports_Sorting" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" ForeColor="Black" OnRowCommand="gvwReports_RowCommand" OnRowDataBound="gvwReports_RowDataBound">
                <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
                <RowStyle CssClass="GridViewRowStyle" />
                <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
                <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
                <HeaderStyle CssClass="GridViewHeaderStyle" BackColor="#333333" Font-Bold="True" ForeColor="White" />
                <Columns>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:CheckBox ID="GRChkBox" runat="server"  
                                Checked="false" />
                        </ItemTemplate>
                        <HeaderTemplate>
                            <asp:CheckBox ID="GRChkALL" runat="server" AutoPostBack="True" OnCheckedChanged="GRChkALL_CheckedChanged"
                                ToolTip="Select or deselect all reports" Checked="false" />
                        </HeaderTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="40" />
                        <ItemStyle HorizontalAlign="Center" Width="40" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="No">
                        <ItemTemplate>
                            <asp:Label ID="xCol01" runat="server" Text="<%#Container.DataItemIndex+1  %>"></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="30" />
                        <ItemStyle Width="30" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Organization"
                        SortExpression="OrgIDName">
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:Label ID="xCol02" runat="server" Text='<%#Microsoft.Security.Application.Encoder.HtmlEncode(Convert.ToString(Eval("OrgIDName")))%>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Site" SortExpression="SiteIDName">
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:Label ID="xCol03" runat="server" Text='<%#Microsoft.Security.Application.Encoder.HtmlEncode(Convert.ToString(Eval("SiteIDName")))%>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Cost Centre"
                        SortExpression="CostCentreIDName">
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:Label ID="xCol04" runat="server" Text='<%#Microsoft.Security.Application.Encoder.HtmlEncode(Convert.ToString(Eval("CostCentreIDName")))%>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Report File"
                        SortExpression="ReportFileName">
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:LinkButton ID="lblFileName" runat="server" Text='<%#Microsoft.Security.Application.Encoder.HtmlEncode(Convert.ToString(Eval("ReportFileName")))%>'
                                OnClientClick='<%# string.Format("window.open(\"httpgetbillreport.aspx?ID={0}&DownloadID={1}\",\"mywindow\",\"width=400,height=200\");return false;", Eval("ID"), Eval("DownloadID")) %>'></asp:LinkButton>
                            <asp:Label ID="lblRepositoryID" runat="server" Text='<%#Microsoft.Security.Application.Encoder.HtmlEncode(Convert.ToString(Eval("ID")))%>' Visible="false">
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Created Date"
                        SortExpression="CreatedDateTime">
                        <ItemTemplate>
                            <asp:Label ID="xCol05" runat="server" Text='<%#Microsoft.Security.Application.Encoder.HtmlEncode(Convert.ToString(Eval("CreatedDateTime","{0:dd/MM/yyyy hh:mm:ss tt}")))%>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Released Date"
                        SortExpression="ReleasedDateTime">
                        <ItemTemplate>
                            <asp:Label ID="xCol06" runat="server" Text='<%#Microsoft.Security.Application.Encoder.HtmlEncode(Convert.ToString(Eval("ReleasedDateTime","{0:dd/MM/yyyy hh:mm:ss tt}")))%>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Released" SortExpression="IsReleasedYesNo">
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:Label ID="xCol07" runat="server" Text='<%#Microsoft.Security.Application.Encoder.HtmlEncode(Convert.ToString(Eval("IsReleasedYesNo")))%>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Version" SortExpression="Version">
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:Label ID="xCol08" runat="server" Text='<%#Microsoft.Security.Application.Encoder.HtmlEncode(Convert.ToString(Eval("Version")))%>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Changes" SortExpression="">
                        <ItemTemplate>
                            <asp:LinkButton ID="xCol09" runat="server" CommandName="editdata"  CommandArgument='<%#Common.EncryptData(Convert.ToString(Eval("ID")))%>' Text='View' PostBackUrl='<%#"ViewChanges.aspx?token=" + Common.CreateToken()%>'></asp:LinkButton>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="40" />
                        <ItemStyle HorizontalAlign="Center" Width="40" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="Locked" SortExpression="Locked">
                        <ItemTemplate>
                            <asp:Label ID="xCol10" runat="server" Text='<%#Eval("Locked").ToString() == "1"? "Locked":"Unlocked"%>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" Width="40" />
                        <ItemStyle HorizontalAlign="Center" Width="40" />
                    </asp:TemplateField>
                </Columns>
                <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
            </asp:GridView></div>
            <br />
            <asp:Button ID="BtnRelease" runat="server" CssClass="ui-state-default ui-corner-all"
                Text="Release" Visible="false" OnClick="BtnRelease_Click" />
            <asp:ConfirmButtonExtender ID="BtnRelease_ConfirmButtonExtender" runat="server" ConfirmText="Click OK to release report"
                TargetControlID="BtnRelease">
            </asp:ConfirmButtonExtender>
            &nbsp;
            <asp:Button ID="BtnUnrelease" runat="server" CssClass="ui-state-default ui-corner-all"
                Text="Unrelease" Visible="false" OnClick="BtnUnrelease_Click" />
            <asp:ConfirmButtonExtender ID="BtnUnrelease_ConfirmButtonExtender" runat="server"
                ConfirmText="Click OK to unrelease report" TargetControlID="BtnUnrelease">
            </asp:ConfirmButtonExtender>
            &nbsp;
            <asp:Button ID="BtnDownload" runat="server" CssClass="ui-state-default ui-corner-all"
                Text="Download Zip" Visible="false" OnClick="BtnDownload_Click" ToolTip="Download selected report(s) in zip file format" />
            <asp:ConfirmButtonExtender ID="BtnDownload_ConfirmButtonExtender" runat="server"
                ConfirmText="Click OK to download selected report(s) in zip file format" TargetControlID="BtnDownload">
            </asp:ConfirmButtonExtender>
        </ContentTemplate>
        <Triggers>
            <asp:PostBackTrigger ControlID="BtnDownload" />
        </Triggers>
    </asp:UpdatePanel>
    <asp:UpdateProgress ID="updateprogress1" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
        <ProgressTemplate>
            <uc5:ucInProgress ID="ucInProgress1" runat="server" />
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:HiddenField runat="server" ID="xReportID" Value="0" />   
</asp:Content>
